<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>06Getter和Setter</title>
</head>
<body>
<div id="app">
    计算器：{{ counter }}<br>
    {{ fullName }}
</div>
<script src="../vue.global.3.0.5.js"></script>
<script>
    //声明一个选项对象
    const App={
        //初始数据
        data() {
            return {
                counter: 100,
                firstName: "Lee.",
                lastName: "Long"
            }
        },
        computed: {
            //1、简写版的计算属性是只读的不能赋值
            //fullName() {
            //    return this.firstName + this.lastName;
            //}
            //2、完整版的计算属性是可读可写
            fullName: {
                get() {
                    return this.firstName + this.lastName;
                },
                set(value) {
                    const str = value.split('.');
                    this.firstName = str[0] + '.';
                    this.lastName = str[1];
                }
            }
        }
    }

    //全局API对象，创建应用对象返回(选项对象).挂载方法(DOM节点)
    const vm = Vue.createApp(App).mount("#app");
</script>
</body>
</html>